﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title></title>
    
</head>
<body>
    <div>
        <link href="../../kindeditor/themes/default/default.css" rel="stylesheet" />
        <link href="../../kindeditor/plugins/code/prettify.css" rel="stylesheet" />
        <script src="../../kindeditor/kindeditor-all.js"></script>
        <script src="../../kindeditor/lang/zh-CN.js"></script>
        <script src="../../kindeditor/plugins/code/prettify.js"></script>
        <table class="easyui-datagrid" id="roomlist" data-options="rownumbers:true,toolbar:'#roomtb'"></table>

        <div id="roomtb" style="padding: 2px 5px;">
            <div id="ft" style="padding: 2px 5px;">
                <a href="#" class="easyui-linkbutton" iconcls="icon-add" onclick="addroom()" plain="true">添加房间</a>
            </div>
        </div>

        <div id="roomaddwin" class="easyui-dialog" title="添加" style="width: 450px; height: 300px;"
            data-options="iconCls:'icon-add',resizable:true,modal:true,closed: true">
            <div style="margin: 0 auto; text-align: center;">
                <%using (Html.BeginForm("addRoom", "admin", FormMethod.Post, new { enctype = "multipart/form-data" }))%>
        <%{%>
                <table style="width:69%;">
                      <tr>
                        
                        <td class="auto-style4">房间类型：</td>
                        <td class="auto-style3">
                            <select id="Selecttype" name="Selecttype">
                                <%hotel.BLL.tb_roomtype rt = new hotel.BLL.tb_roomtype();
                                  List<hotel.Model.tb_roomtype> li = rt.GetModelList("");
                                  foreach(hotel.Model.tb_roomtype mod in li) 
                                  { %>
                                <option value="<%=mod.ID %>"><%=mod.typename %></option>
                                <%} %>
                            </select></td>
                    </tr>
                   
                    <tr>
                        
                        <td class="auto-style4">房间名称：</td>
                        <td class="auto-style3">
                            <input id="roomName" name="roomName" type="text" /></td>
                        
                    </tr>
                     <tr>
                        
                        <td class="auto-style4">简介：</td>
                        <td class="auto-style3">
                            <input id="info" name="info" type="text" /></td>
                        
                    </tr>
                      
                    <tr>
                       
                        <td class="auto-style4">展示图片：</td>
                        <td class="auto-style3">
                            <input id="file" name="file" type="file" accept=".png,.jpg,.gif,.bmp" /></td>
                    </tr>
                </table>
                <input  type="submit" value="添加" />  
                <%} %>

            </div>
        </div> 

     

        <script type="text/javascript">
            $('#roomlist').datagrid({
                url: '../admin/GetRoomList',
                singleSelect: true,
                columns: [[
                    { field: 'title', title: '名字', width: 70 },
                    { field: 'typename', title: '属于', width: 70 },
                    { field: 'context', title: '简介', width: 250 },
                    { field: 'rooms', title: '房间个数', width: 70 },
                    { field: 'bednum', title: '床位个数', width: 70 },
                    { field: 'Price', title: '价格', width: 40 },
                    { field: 'url', title: '图片路径', width: 170 },
                   
                    {
                        field: 'opt', title: '删除', width: 100, align: 'center',
                        formatter: function (value, rec) {
                            var btn = "<a href=" + "#" + " class=" + "easyui-linkbutton" + " iconcls=" + "icon-remove" + " onclick=" + "Deletroom(" + rec.ID + ")" + " plain=" + "true" + ">删除</a>";
                             return btn;
                          }
                     }
                     ]]
            });
            function addroom() {
                $('#roomaddwin').dialog('open');
            };

            function Deletroom(id) {
                $.post("../admin/DelRoom", { ID: id },
                function (data) {
                    if (data == false) {
                        $.messager.alert('未知错误', '删除失败.');
                    }
                    else {
                        $.messager.alert('提示', '删除成功');
                        $('#roomlist').datagrid('load', {
                            code: '01',
                            name: 'name'
                        });
                    }
                });
            };
         
        </script>
        <style type="text/css">
        .auto-style3 {
            width: 191px;
        }
        #Text3 {
            height: 106px;
            width: 224px;
        }
            #Select1 {
                width: 144px;
            }
           
            .auto-style4 {
                width: 92px;
            }
           
    </style>
    </div>
</body>
</html>
